<!DOCTYPE html>
<html class="no-js" lang="zxx">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <title>Post Job - JobGrids Job Portal HTML Template.</title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.svg" />
  <!-- Place favicon.ico in the root directory -->

  <!-- Web Font -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
        rel="stylesheet">

  <!-- ========================= CSS here ========================= -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
  <link rel="stylesheet" href="assets/css/LineIcons.2.0.css" />
  <link rel="stylesheet" href="assets/css/animate.css" />
  <link rel="stylesheet" href="assets/css/tiny-slider.css" />
  <link rel="stylesheet" href="assets/css/glightbox.min.css" />
  <link rel="stylesheet" href="assets/css/main.css" />

</head>

<body>
<!--[if lte IE 9]>
<p class="browserupgrade">
  You are using an <strong>outdated</strong> browser. Please
  <a href="https://browsehappy.com/">upgrade your browser</a> to improve
  your experience and security.
</p>
<![endif]-->

<div id="loading-area"></div>

<!-- Start Header Area -->
<header class="header">
  <div class="navbar-area">
    <div class="container">

      <div class="row align-items-center">

        <div class="col-lg-12">
          <nav class="navbar navbar-expand-lg">
            <a class="navbar-brand logo" href="index-hr.html">
              <img class="logo1" src="assets/images/logo/logo.svg" alt="Logo" />
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse"
                    data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse sub-menu-bar" id="navbarSupportedContent">
              <ul id="nav" class="navbar-nav ml-auto">
                <li class="nav-item">
                  <a  href="index-hr.html">主页</a>
                </li>



                    <li class="nav-item">
                      <a  href="browse-jobs.html">职位搜索</a>
                    </li>

                <li class="nav-item"><a href="#">职位管理 </a>
                  <ul class="sub-menu">
                    <li><a href="post-job.html">发布职位</a></li>
                    <li><a href="manage-jobs.html">职位查看与编辑</a></li>
                    <li><a  href="have-manage-resumes.html">已处理申请</a></li>
                    <li><a  href="manage-resumes.html">待处理申请</a></li>

                  </ul>
                </li>



                <li class="nav-item">
                  <a href="blog-grid-sidebar.html">论坛</a></li>


                <li class="nav-item"><a href="contact.html">联系我们 </a> </li>


                <li class="nav-item"><a href="#">其他</a>
                  <ul class="sub-menu">
                    <!-- <li><a href="index.html" onclick="logout()">Log Out</a></li> -->
                    <li><a onclick="checkloginuser()">Personal Info</a></li>
                    <li><a href="about-us.html" onclick="addtoken()">About Us</a></li>
                    <li><a href="job-list.html">Job List</a></li>
                    <li><a href="job-details.html">Job Details</a></li>
                    <li><a href="resume.html">Resume Page</a></li>
                    <li><a href="privacy-policy.html">Privacy Policy</a></li>
                    <li><a href="faq.html">Faq</a></li>
                    <li><a href="pricing.html">Our Pricing</a></li>
                    <li><a href="404.html">404 Error</a></li>
                    <li><a href="mail-success.html">Mail Success</a></li>
                  </ul>
                </li>

                <li class="nav-item">
                  <a href="#" class="active">个人中心</a>
                  <ul class="sub-menu">
                    <li><a class="active" href="showhrinfo.html">信息编辑</a></li>
                    <li><a href="job-alerts.html">消息提醒</a></li>
                    <li><a href="manage-blog.html">管理博客</a></li>
                  </ul>
                </li>
                <li class="nav-item login">

                  <a href="showhrinfo.html" id="shownameid" >
                  </a>
                  <ul class="sub-menu">
                    <li><a href="index.html" onclick="logout()">退出登录</a></li>
                  </ul>
                </li>
              </ul>
            </div>
            <!-- navbar collapse -->
            <!--登录显示用户名的地方，点击进入到个人中心界面-->



          </nav>
          <!-- navbar -->
        </div>
      </div>
      <!-- row -->
    </div>
    <!-- container -->
  </div>
  <!-- navbar area -->
</header>
<!-- End Header Area -->



<section class="job-post section">
  <div class="container">
    <div class="row">
      <div class="col-lg-10 offset-lg-1 col-12">
        <div class="job-information">
          <h3 class="title">Hr个人信息</h3>
          <form id="hrupdateform" method="post" onsubmit="return false">

            <input style="display:none"name="hrid" id="hrdetailid" >

            <div class="row">
              <div class="col-lg-12">
                <div class="form-group">
                  <label>Hr姓名*</label>
                  <input id="hrdetailname" class="form-control" type="text" name="hrname">
                </div>
              </div>
              <div class="col-lg-12">
                <div class="form-group">
                  <label>Hr电话号码(登录所用的用户名)*</label>
                  <input id="hrdetailtel" class="form-control" type="text" name="hrTel">
                </div>
              </div>
              <div class="col-lg-12">
                <div class="form-group">
                  <label>Hr登录密码*</label>
                  <input id="hrdetailpwd"class="form-control" type="text" name="hrpwd">
                </div>
              </div>
              <div class="col-lg-12">
                <div class="form-group">
                  <label>Hr职称*</label>
                  <input id="hrdetailpos"class="form-control" type="text" name="hrpos">
                </div>
              </div>
            </div>
            <div class="form-group mb-8 button">
              <button class="btn " id="hrmodifybtn" onclick="hrmodify()" >修改个人信息
              </button>
              <button class="btn " id="hrsavebtn" onclick="hrsave()" >保存个人信息
              </button>
            </div>
          </form>


            <h3 class="title">所属公司信息</h3>
            <form  id="companyupdateform" method="post" onsubmit="return false" >
              <input id="companydetailid" name="updatecomid" style="display:none">
              <input id="companyhrid" name="updatecomhrid" style="display:none">
              <div class="row">
                <div class="col-lg-12">
                  <div class="form-group">
                    <label>公司名称*</label>
                    <input id="companydetailname"required class="form-control" type="text" name="companyname">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>统一社会信用代码*</label>
                    <input id="companydetailusc"required class="form-control" type="text" name="USCC">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>工商注册号*</label>
                    <input id = "companydetailbrn"required class="form-control" type="text" name="BRN">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>经营状态*</label>
                    <select required class="select" id="operatatusid" name="operationstatus">
                      <option value="存续">存续</option>
                      <option value="在业">在业</option>
                      <option value="吊销">吊销</option>
                      <option value="注销">注销</option>
                      <option value="迁入">迁入</option>
                      <option value="迁出">迁出</option>
                      <option value="停业">停业</option>
                      <option value="清算">清算</option>
                    </select>
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>企业类型*</label>
                    <input required id="compdetailtype"class="form-control" type="text" name="Comptype">
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label>经营范围*</label>
                    <input id="comdetailscope"required class="form-control" type="text" name="busscope">
                  </div>
                </div>
              </div>

              <div class="row">
                <div class="col-lg-12">
                  <div class="form-group">
                    <label>所属行业*</label>
                    <input id="detailindsector"required class="form-control" type="text" name="indsector">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>法定代表人*</label>
                    <input id="legalrep"required class="form-control" type="text" name="Legalrep">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>注册资本*</label>
                    <input id="registercap" required class="form-control" type="text" name="registercap">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>成立日期*</label>
                    <input id="estdetail"required class="form-control" type="text" name="estabdate">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>经营期限*</label>
                    <input id="operiodid" required class="form-control" type="text" name="operatperiod">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>登记机关*</label>
                    <input required class="form-control" type="text" id="regauthdetail" name="registerauth">
                  </div>
                </div>
                <div class="col-lg-6 col-md-6">
                  <div class="form-group">
                    <label>注册地址*</label>
                    <input required class="form-control" type="text" id="detailaddr" name="registeraddr">
                  </div>
                </div>
                <!--<div class="col-lg-12">
                  <div class="choose-img">
                    <p>Logo (Optional)</p>
                    <label for="img">Select image:</label>
                    <input type="file" id="img" name="img" accept="image/*">
                    <p>Maximum file size: 2 MB</p>
                  </div>
                </div>-->
              </div>
              <div class="form-group mb-8 button">
                <button class="btn " id="companymodifybtn" onclick="companymodify()" >修改公司信息
                </button>
                <button class="btn " id="companysavebtn" onclick="companysave()" >保存公司信息
                </button>
              </div>
            </form>


        </div>
      </div>
    </div>
  </div>
</section>




<!-- Start Footer Area -->
<footer class="footer">
  <div class="footer-bottom">
    <div class="container">
      <div class="inner">
        <div class="row">
          <div class="col-lg-6 col-md-6 col-12">
            <div class="left">
              <p><a target="_blank" >软件工程大作业</a></p>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-12">
            <div class="right">
              <ul>
                <li><a href="privacy-policy.html">用户手册</a></li>
                <li><a href="#">项目文档</a></li>
                <li><a href="https://gitee.com/Yuan-Wi/software-engineering-team/tree/master/">gitee</a></li>
                <li><a href="contact.html">联系我们</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- End Footer Middle -->
</footer>
<!--/ End Footer Area -->

<!-- ========================= scroll-top ========================= -->
<a href="#" class="scroll-top btn-hover">
  <i class="lni lni-chevron-up"></i>
</a>

<!-- ========================= JS here ========================= -->

<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<script src="assets/js/wow.min.js"></script>
<script src="assets/js/tiny-slider.js"></script>
<script src="assets/js/glightbox.min.js"></script>
<script src="assets/js/main.js"></script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">
  //===========最初需要完成hr的内容的加载
    $(document).ready(function(){
   $.ajax({
    url: "http://localhost:8080/hrdetail",
    type: "GET",
    data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
    success: function(result){
  if(result.code==200){
      // 获取所有的keys
    const keys = Object.keys(result);

    // 循环获取对应的value并显示
    keys.forEach(key => {

      if(key=="data"){
      //temkeys=hr,company
      const temkeys = Object.keys(result[key]);
      temkeys.forEach(temkey => {
        if(temkey=="hr"){
          const hr = result["data"]["hr"];
         // alert(hr.hrName+hr.hrTel+hr.hrPwd);
           document.getElementById("hrdetailid").value=hr.hrId;

           document.getElementById("companyhrid").value=hr.hrId;
          document.getElementById("hrdetailname").value=hr.hrName;
          document.getElementById("hrdetailtel").value=hr.hrTel;
          document.getElementById("hrdetailpwd").value=hr.hrPwd;
          document.getElementById("hrdetailpos").value=hr.hrPos;
        }
        else if(temkey=="company"){
          const com = result["data"]["company"];
          document.getElementById("companydetailid").value=com.companyId;
          document.getElementById("companydetailname").value=com.companyName;
          document.getElementById("companydetailusc").value=com.companyUscc;
          document.getElementById("companydetailbrn").value=com.companyBrn;
          document.getElementById("operatatusid").value=com.companyOpstatus;
          document.getElementById("compdetailtype").value=com.companyComptype;
          document.getElementById("comdetailscope").value=com.companyBusscope;
          document.getElementById("detailindsector").value=com.companyIndsector;
          document.getElementById("legalrep").value=com.companyLegalrep;
          document.getElementById("registercap").value=com.companyRegcap;
          document.getElementById("estdetail").value=com.companyEstdate;
          document.getElementById("operiodid").value=com.companyOpperiod;
          document.getElementById("regauthdetail").value=com.companyRegauth;
          document.getElementById("detailaddr").value=com.companyRegaddr;
        }
      });
      }
    });
    //var hrform = document.getElementById("hrupdateform");
    //var companyform = document.getElementById("companyupdateform");
    //遍历表单设置元素readonly
      $('input').attr('readonly', true);
       $("#operatatusid").prop('disabled', true);
       $("#hrsavebtn").attr("disabled", true);
       $("#companysavebtn").attr("disabled", true);
    /*$("#hrupdateform").each(
    function(){
      $(this).prop('readonly', true);
    );
    $("companyupdateform").each(
      $(this).prop('readonly', true);
    );*/
//select只读
    /*$("#operatatusid").on("mousedown", function(event) {
  event.preventDefault();
});*/


   }
    else {
      alert(result.code+result.msg);
        }
        },
        error: function(){
        alert("请刷新重试");
        },
         });
          });
  function hrmodify(){
  //设置save可用，表格元素可修改
  alert("modify");
  $("#hrsavebtn").attr("disabled", false);
  $('#hrupdateform input[readonly]').removeAttr('readonly');
  };
  function hrsave(){
  //设置save不可用，表格元素提交后台修改
  alert("save");
  $.ajax({
      url: "http://localhost:8080/updatehrdetail",
     type: "POST",
     dataType: "json",
     data: $('#hrupdateform').serialize(),
     success: function(result){
     if(result.code==200){
     alert("个人信息修改成功");
     //遍历表单设置元素readonly,按钮不可修改
     $('#hrupdateform input').prop('readonly', true);
     $("#hrsavebtn").attr("disabled", true);
     }
     else{
     alert(result.code);
     }
     },
     error: function(){
     alert("修改个人信息失败，稍后重试");
     },
  });
  };
  function companymodify(){
  alert("modify");
  $("#companysavebtn").attr("disabled", false);
  $('#companyupdateform input[readonly]').removeAttr('readonly');
  $("#operatatusid").prop('disabled', false);
  };
  //保存修改后的公司信息
  function companysave(){
    $.ajax({
      url: "http://localhost:8080/updatecompanydetail",
     type: "POST",
     dataType: "json",
     data: $('#companyupdateform').serialize(),
     success: function(result){
     if(result.code==200){
     alert("公司信息修改成功");
     //遍历表单设置元素readonly,按钮不可修改
     $('#companyupdateform input').prop('readonly', true);
     $("#companysavebtn").attr("disabled", true);
     //列表
     $("#operatatusid").prop('disabled', true);
     }
     else{
     alert(result.code+"修改失败");
     }
     },
     error: function(){
     alert("修改公司信息失败，稍后重试");
     },
  });
  };
   //===========最初需要完成名字的显示
  $(document).ready(function(){


         /*   alert("新方法");*/
						$.ajax({
    url: "http://localhost:8080/mylogingetusername",
    type: "GET",
    data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
    success: function(result){
     // alert(result.code);
      if(result.code==200){
      alert(result.msg);
      document.getElementById('shownameid').textContent = "欢迎"+result.msg+"登录";
      }
      else {
        alert(result.code+result.msg);
        }
    },
    error: function(){
    alert("请刷新重试");
    },
  });
				});

  function logout(){
 window.localStorage.removeItem('user');
 location.href="http://localhost/static/html/index.html";
};
</script>
</body>

</html>
